package deibay.server.commands;

import deibay.messages.Message;
import deibay.messages.ReplySubscribeItemMsg;
import deibay.messages.SubscribeItemMsg;
import deibay.server.ServerManager;
import deibay.server.eventargs.SendMessageEventArg;
import deibay.server.eventargs.SubscribeItemEventArg;
import deibay.server.events.SendMessageEvent;
import deibay.server.events.SubscribeItemEvent;
import deibay.users.User;

public class SubscribeItemCommand extends Command{

	public SubscribeItemCommand(User user, Message msg) {
		super(user, msg);
	}

	@Override
	public void execute() {
		String id = ((SubscribeItemMsg)message).getID();
		ServerManager.getInstance().getEventManager().fireEvent(new SubscribeItemEvent(new SubscribeItemEventArg(user, id)));
		ReplySubscribeItemMsg msg = new ReplySubscribeItemMsg(ReplySubscribeItemMsg.class.getSimpleName(), true);
		ServerManager.getInstance().getEventManager().fireEvent(new SendMessageEvent(new SendMessageEventArg(user.getId(), msg)));
	}

}
